package com.mondo.financialwallet.presentation.ui.adapter;

import android.content.res.Resources;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mondo.financialwallet.R;
import com.mondo.financialwallet.presentation.model.HotProducts;

/**
 * 热门产品
 */
public class HotProductsAdapter extends BaseQuickAdapter<HotProducts, BaseViewHolder> {

    public HotProductsAdapter(){
        this(R.layout.item_hot_products);
    }

    private HotProductsAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, HotProducts item) {
        Resources resources = helper.itemView.getContext().getResources();
        helper.setText(R.id.name_text, item.getTitle());
        helper.setText(R.id.annualized_rate_text, item.getAnnualizedRate());
        helper.setText(R.id.minimum_day_text, String.format(resources
                .getString(R.string.text_placeholder_day), item.getMinimumDay()));

        String productType = item.getType() == 0 ? "活期" : "定期";

        // TODO 中文符号
        helper.setText(R.id.product_income_rule_text,
                "$" + item.getMinimumAmount() + "起购 " + productType + "收益");
    }
}
